import service from '@/utils/request'

const BASE_URL = 'api-user'

//获取账号列表
export function userList(data) {
    return service({
        url: `${BASE_URL}/users`,
        method: 'get',
        params: data
    })
}

//统计学校入驻机构数量
export const getOrganReport = () => {
    return service({
        url: `${BASE_URL}/user/organ/report`,
        method: 'get'
    })
}

//统计学校下开课数量
export const getCourseReport = () => {
    return service({
        url: `${BASE_URL}/user/course/report`,
        method: 'get'
    })
}


//获取学校列表
export function schoolList(data) {
    return service({
        url: `${BASE_URL}/user/schools`,
        method: 'get',
        params: data
    })
}

//获取机构列表
export function organList(data) {
    return service({
        url: `${BASE_URL}/user/organs`,
        method: 'get',
        params: data
    })
}

// 获取详情
export function userDetail(userId, type) {
    return service({
        url: `${BASE_URL}/user/${userId}` + '?type=' + type,
        method: 'get'
    })
}

// 新增
export function addUser(data) {
    return service({
        url: `${BASE_URL}/user`,
        method: 'post',
        data
    })
}

// 编辑
export function editUser(data) {
    return service({
        url: `${BASE_URL}/user`,
        method: 'put',
        data
    })
}


//审批操作
export function handleAudit(data) {
    return service({
        url: `${BASE_URL}/user/organ/audit`,
        method: 'put',
        data: data
    })
}


//启用/停用
export function enableAccount(userId) {
    return service({
        url: `${BASE_URL}/user/enable/${userId}`,
        method: 'put',
    })
}


// 获取学校列表
export function userSchoolList() {
    return service({
        url: `${BASE_URL}/user/school/simple`,
        method: 'get'
    })
}

//获取审批原因
export function getAuditMessage(userId) {
    return service({
        url: `${BASE_URL}/user/organ/${userId}/audit-message`,
        method: 'get'
    })
}

//重置用户密码为手机号码
export function resetPwd(userId) {
    return service({
        url: `${BASE_URL}/user/pwd/${userId}`,
        method: 'put'
    })
}

//获取用户扩展信息
export function getUserExtend(userId, type) {
    return service({
        url: `${BASE_URL}/user/extend/${userId}?type=${type}`,
        method: 'get'
    })
}
